<template>
  <div class="userInfo">
    <div class="userIcon">
      <img class="userIconImg" src="../assets/touxiang.jpg" title="头像" />
    </div>
    <div class="userData">
      <p class="userName">{{ uName }}</p>
      <p class="userDept">@{{ uDept }}</p>
    </div>
    <div class="userLogout">
      <svg
        t="1671064265422"
        class="icon"
        viewBox="0 0 1024 1024"
        version="1.1"
        xmlns="http://www.w3.org/2000/svg"
        p-id="6242"
        width="30"
        height="45"
        @click="onLogout"
      >
        <path
          d="M918.4 489.6l-160-160c-12.8-12.8-32-12.8-44.8 0-12.8 12.8-12.8 32 0 44.8l105.6 105.6L512 480c-19.2 0-32 12.8-32 32s12.8 32 32 32l307.2 0-105.6 105.6c-12.8 12.8-12.8 32 0 44.8 6.4 6.4 12.8 9.6 22.4 9.6 9.6 0 16-3.2 22.4-9.6l160-163.2c0 0 0-3.2 3.2-3.2C931.2 518.4 931.2 499.2 918.4 489.6z"
          p-id="6243"
        ></path>
        <path
          d="M832 736c-19.2 0-32 12.8-32 32l0 64c0 19.2-12.8 32-32 32L224 864c-19.2 0-32-12.8-32-32L192 192c0-19.2 12.8-32 32-32l544 0c19.2 0 32 12.8 32 32l0 64c0 19.2 12.8 32 32 32s32-12.8 32-32L864 192c0-54.4-41.6-96-96-96L224 96C169.6 96 128 137.6 128 192l0 640c0 54.4 41.6 96 96 96l544 0c54.4 0 96-41.6 96-96l0-64C864 748.8 851.2 736 832 736z"
          p-id="6244"
        ></path>
      </svg>
    </div>
  </div>
</template>

<script>
import { mapActions } from 'vuex';
export default {
  name: 'UserInfo',
  props: ['uName', 'uDept', 'uIconUrl', 'depth'],
  methods: {
    ...mapActions(['RenewMenu', 'Login', 'InitMenu', 'refreshUser', 'Logout']),
    onLogout() {
      this.Logout();
      this.$router.push('/');
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.userInfo {
  border: 2px solid #f8f8ff;
  border-radius: 5px;
  background-color: #87cefa;
  display: flex;
}
.userIcon {
  height: 100%;
  margin-top: 5px;
  margin-left: 5px;
}
.userIconImg {
  width: 48px;
  border-radius: 50%;
}
.userData {
  flex-grow: 1;
  padding-left: 15px;
  padding-top: 8px;
  color: black;
}
.userLogout {
  width: 30px;
  margin-right: 10px;
  padding-top: 8px;
}
.userName {
  font-size: 0.9em;
  font-weight: 600;
}
.userDept {
  font-size: 0.8em;
  margin-top: 5px;
  color: #696969;
}
</style>
